import { request } from "@utils/http";
import {
  HospitalSetItem,
  ReqAddHospitalSetParams,
  ReqGetHospitalSetParams,
  ReqGetHospitalSetResponse,
  ReqUpdateHospitalSetParams,
} from "./model/hospitalSetTypes";
// 声明获取医院设置的get函数声明
// 该函数的四个形参 第一个第二个形参为必须传入,第三个第四个为可选项
export function ReqGetHospitalSet({
  page,
  limit,
  ...args
}: ReqGetHospitalSetParams) {
  //泛型的第二个值是限制响应体数据response.data
  return request.get<any, ReqGetHospitalSetResponse>(
    `/admin/hosp/hospitalSet/${page}/${limit}`,
    {
      params: args,
    }
  );
}

// 声明一个添加医院信息的函数
/**
 * @param hospital 医院的信息
 * @returns Promise<null>
 */
export function ReqAddHospitalSet(hospital: ReqAddHospitalSetParams) {
  return request.post("/admin/hosp/hospitalSet/save", hospital);
}
/**
 *
 * @param id 通过id获取医院信息
 * @returns Promise
 */
export function ReqGetHospitalSetById(id: string) {
  return request.get<any, HospitalSetItem>(`/admin/hosp/hospitalSet/get/${id}`);
}
/**
 *
 * @param hospital 医院的信息更改
 * @returns Promise<null>
 */
export function ReqUpdateHospitalSet(hospital: ReqUpdateHospitalSetParams) {
  return request.put<any, null>("/admin/hosp/hospitalSet/update", hospital);
}

/**
 *
 * @param id 通过id获取医院信息
 * @returns Promise
 */
export function ReqRemoveHospital(id: string) {
  return request.delete(`/admin/hosp/hospitalSet/remove/${id}`);
}

export function ReqBatchRemoveHospital(idList: number[]) {
  return request.delete("admin/hosp/hospitalSet/batchRemove", {
    data: idList,
  });
}
